package pe.com.pgn.consolidadorventas.servidorestacion.ws.security;

import java.io.InputStream;

import pe.com.pgn.consolidadorventas.servidorestacion.ws.security.service.WsSeguridadService;

import com.sun.xml.wss.XWSSProcessor;
import com.sun.xml.wss.XWSSProcessorFactory;
import com.sun.xml.wss.XWSSecurityException;

public class SecurityConfigProcessorFactory {
    protected static XWSSProcessor xwssProcessor;

    public static XWSSProcessor getXWSSProcessor(WsSeguridadService wsSeguridadService) throws XWSSecurityException {
        if (xwssProcessor == null) {
            InputStream serverConfig = SecurityConfigProcessorFactory.class.getResourceAsStream("/pe/com/pgn/consolidadorventas/servidorestacion/ws/security/security-config.xml");
            XWSSProcessorFactory factory = XWSSProcessorFactory.newInstance();
            xwssProcessor = factory.createProcessorForSecurityConfiguration(serverConfig, new SecurityEnvironmentHandler(wsSeguridadService));
        }
        return xwssProcessor;
    }
}